from django.db import models
class User(models.Model):
    username = models.CharField(max_length=20)
    password = models.CharField(max_length=100)

class UserExtension(models.Model): # 实现一对一
    birthday = models.DateTimeField(null=True)
    school = models.CharField(blank=True,max_length=50)
    user = models.OneToOneField("User", on_delete=models.CASCADE)

class Article(models.Model):
    title = models.CharField(max_length=100)
    content = models.TextField()
    # author_id 外键
    author = models.ForeignKey("User",on_delete=models.CASCADE,related_name="articles")
    tags = models.ManyToManyField("Tag", related_name="articles")

class Tag(models.Model):
    name = models.CharField(max_length=50)

class Comment(models.Model):
    content = models.TextField()
    orrgin_comment = models.ForeignKey("self",on_delete=models.CASCADE)